#include<bits/stdc++.h> 
using namespace std;
//	与乙级1019一致
string z, f;
void sort_(string s){
	char ss[4] = {s[0], s[1], s[2], s[3]};
	sort(ss, ss+4);
	stringstream sz, sf;
	sf<<ss[0]<<ss[1]<<ss[2]<<ss[3];
	sz<<ss[3]<<ss[2]<<ss[1]<<ss[0];
	z = sz.str();
	f = sf.str();
}
int main(){
	string n;
	cin>>n;
	n = "0000"+n;
	n = n.substr(n.length()-4);
	while(true){
		sort_(n);
		int z_ = stoi(z), f_ = stoi(f);
		int nn = z_ - f_;
		if(nn==0){
			n = "0000";
			cout<<z<<" - "<<f<<" = "<<n<<endl;
			break;
		}
		else if(nn==6174){
			cout<<z<<" - "<<f<<" = "<<nn<<endl;
			break;
		}
		else if(nn<1000){
			stringstream ss;
			ss<<"0"<<nn;
			n = ss.str();
			cout<<z<<" - "<<f<<" = "<<n<<endl;
		}
		else{
			stringstream ss;
			ss<<nn;
			n = ss.str();
			cout<<z<<" - "<<f<<" = "<<n<<endl;
		}
	}
	return 0;
} 